home *** CD-ROM | disk | FTP | other *** search
- Path: news.ccs.queensu.ca!news
- From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
- Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
- Subject: Re: C++ with Zapp vs. Delphi
- Date: Fri, 19 Jan 1996 13:10:10 GMT
- Organization: Queen's University, Kingston
- Message-ID: <30ff9519.1799465@130.15.126.54>
- References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com> <DBk8wg2yqjbB083yn@iaccess.za> <4d7pmb$48c8@tigger.cc.uic.edu> <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu> <30fe666e.3349285@130.15.126.54> <4dmjt8$6sv@crc-news.doc.ca>
- NNTP-Posting-Host: free1-slip213.tele.queensu.ca
- X-Newsreader: Forte Agent .99c/16.141
-
- Slobodan Celenkovic <slobodan@cs.unh.edu> wrote:
-
- >dmurdoch@mast.queensu.ca (Duncan Murdoch) wrote:
-
- >>The way this is done in Delphi is to create a descendant of the
- >>SortedList that overrides the compare method. Instead of forcing you
- >>to only put SortedObjects in the list, this allows you to put anything
- >>there, even non-objects like integers or strings or empty holes, if
- >>that suits your fancy.
-
- >- Each items defines HOW it is compared to other items, and CONTROLS to
- > which items it may be compared. Again makes sense - the item classes
- > should control what they can be compared with, i.e. which comparisons
- > make sense.
-
- No, that's nonsense. Often I want to have a multiply indexed
- database. I can do the same thing with lists: have each item in
- several different lists, so that I can do a fast search on name, or
- address, or telephone area code, or whatever. *The item shouldn't
- handle the compare, the list should.*
-
- >
- >No multiple-inheritance, no operator overloading -> Delphi:
- >===========================================================
- >
- >We can't use the abstract item so:
- >
- >class IntItem(some other class); <- data classes
- >class StringItem(some other class);
- >class MoneyItem(some other class);
-
- Why on earth would you bother to declare those things as classes? If
- you're writing a descendant of the list class, you just make sure it
- can handle the data directly, without the overhead of putting it in a
- class.
-
- >Consequences:
- >
- >- A list class for each item class, hence we end up with twice as many
- > classes. Furthermore we are placing some (little) item specific code
- > into the list class; item specific code really belongs in the item
- > class!
-
- No, you end up with the same number of classes. *You* need to write a
- separate class for each item to be put into the list. *I* need to
- write a separate class for each kind of list. I don't need to put
- sorting information into items; sorting is what the list does.
-
- >- A list may only contain a single type of item. The MI solution's list
- > can store more than one type of item provided that the appropriate
- > comparison functions are defined (so a list contain strings, integeres
- > and money)
-
- Why do you think this? The list can contain *anything*. If I did
- decide to put multiple kinds of items into the list, I would probably
- put them in some kind of common container, but I don't need to. I can
- just do a run-time check of the type of each item. This would require
- them to be classes, but it wouldn't require them to know they're in
- the list.
-
- >Finally to put the discussion into perspective. #1 is obviously the best
- >and most elegant solution. Yet even without MI (Delphi) it is doable. So
- >the price we pay in Delphi is that the solution is not quite as elegant.
-
- No, it's not obvious to me. You still didn't tell me how to put the
- same item into different lists using different sort keys.
-
- > So Pascal is well suited for clients (GUI), C++ for servers.
-
- No, I don't think there is really that much difference. Everything
- I've said above about the "right" way to implement a list would also
- be the "right" way to do it in C++. I suspect MI has been used for
- this just because C++ has MI, not because it makes sense to implement
- a list that way.
-
- Duncan Murdoch
-